package com.example.androidclassseven;

import android.app.Dialog;
import android.app.TimePickerDialog;
import android.os.Bundle;
import android.widget.TimePicker;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;

import java.util.Calendar;

public class MyTimeDialog extends DialogFragment implements TimePickerDialog.OnTimeSetListener {

    @NonNull
    @Override
    public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
        Calendar instance = Calendar.getInstance();
        int min = instance.get(Calendar.MINUTE);
        int s = instance.get(Calendar.SECOND);
        TimePickerDialog timePickerDialog = new TimePickerDialog(getActivity(), this, min, s, true);
        return timePickerDialog;
    }

    @Override
    public void onTimeSet(TimePicker timePicker, int min, int s) {
        Toast.makeText(getContext(), min + ":" + s , Toast.LENGTH_SHORT).show();
    }
}
